home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11151 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: fnnews.fnal.gov!usenet
  2. From: kriol@martian.fnal.gov (Oleg Krivosheev)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: class for accessing indiv bits
  5. Date: 12 Mar 1996 16:38:45 -0600
  6. Organization: FNAL
  7. Sender: kriol@martian.fnal.gov
  8. Message-ID: <vi8ybp60wei.fsf@martian.fnal.gov>
  9. References: <4h3396$l4f@oclc.org>
  10. NNTP-Posting-Host: martian.fnal.gov
  11. In-reply-to: razin@oclc.org's message of Wed, 13 Mar 1996 16:43:16 GMT
  12. X-Newsreader: Gnus v5.1
  13.  
  14.  
  15. Hi, Ira
  16.  
  17.    I was thinking about writing a class for simulating array
  18.    of bits, where each member of that array can serve as a
  19.    binary variable, so for example, by allocating just two
  20.    long integers I would have an array of sizeof(long)*8 
  21.    elements.
  22.  
  23. ok
  24.  
  25.    Having such a class would be a lot of fun. 
  26.  
  27. hmm... ;)
  28.  
  29.    Anybody have it
  30.    implemented already? I have written basic functions for 
  31.    retrieving, setting and toggling bits, but they are very
  32.    C-style. How about overloaded [],=, copy constructors etc
  33.    so it looks just like a regular data type?
  34.  
  35. AFAIK, the C++ DWP contains specialized version of the vector class:
  36. vector<bool>. In HP STL implementation the class name was changed
  37. to bit_vector - take a look at bvector.h. Probably commercial STL
  38. implementations are more close to the C++ DWP.
  39.  
  40.    Ira
  41.  
  42. Oleg
  43.  
  44.